import fetch from 'common/src/utils/fetch';

function findStudentCultureRelList(data) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/findSchemeByPage',
        method: 'post',
        data
    });
}

function findCultureSchemeList(data) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/findCultureForBlind',
        method: 'post',
        data
    });
}

function countNeedBindSchemeStudent(data) {
    return fetch({
        url: '/api/cultureservice/bclStudentCultureRel/countNeedBindSchemeStudent',
        method: 'post',
        data
    });
}

function bindSchemeStudent(data) {
    return fetch({
        url: '/api/cultureservice//bclStudentCultureRel/bindSchemeStudent',
        method: 'post',
        data
    });
}

// function addStudentCultureRelByManual(params) {
//     return fetch({
//         url: '/api/cultureservice/bclCultureScheme/blindScheme' + getParams(params),
//         method: 'get'
//     });
// }
function addStudentCultureRelByManual(data) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/blindScheme',
        method: 'post',
        data
    })
}

// function cancelStudentCultureRelByManual(params) {
//     return fetch({
//         url: '/api/cultureservice/bclCultureScheme/cancelBlind' + getParams(params),
//         method: 'get'
//     });
// }
function cancelStudentCultureRelByManual(data) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/cancelBlind',
        method: 'post',
        data
    })
}

function findSecondScheme(params) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/findSecondScheme' + getParams(params),
        method: 'get'
    });
}

function saveSecondScheme(params) {
    return fetch({
        url: '/api/cultureservice/bclCultureScheme/saveSecondScheme' + getParams(params),
        method: 'get'
    });
}

function getParams(params) {
    var paramsData = [];
    for (const key in params) {
        params[key] &&
            paramsData.push(
                key + '=' + params[key]
            );
    }
    if (paramsData.length)
        return '?' + paramsData.join('&');
    else
        return '';
}

export function getRedisResult(data) {
    return fetch({
        url: 'api/cultureservice/bclStudentCultureRel/result/' + data,
        method: 'get',
        data
    })
}
const associatedApi = {
    'findStudentCultureRelList': findStudentCultureRelList,
    'findCultureSchemeList': findCultureSchemeList,
    'countNeedBindSchemeStudent': countNeedBindSchemeStudent,
    'bindSchemeStudent': bindSchemeStudent,
    'addStudentCultureRelByManual': addStudentCultureRelByManual,
    'cancelStudentCultureRelByManual': cancelStudentCultureRelByManual,
    'findSecondScheme': findSecondScheme,
    'saveSecondScheme': saveSecondScheme,
}

export default associatedApi;